package sctu.edu.java.year2016.team05.wangliwei.day20160606.SQL;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * Created by wangliwei on 2016/6/13.
 */
public class DBClient {


    public static void main(String[] args) {
        String sql = "INSERT INTO student(name,age) VALUES('chen-abc',11)";
        try {
            // 注册mysql 驱动
            Class.forName("com.mysql.cj.jdbc.Driver");


            Connection connection = DriverManager.getConnection(
                    "jdbc:mysql://localhost/javaweb-2016",
                    "root",
                    ""
            );

            Statement statement = connection.createStatement();

            statement.executeQuery(sql);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }
}